<%@page import="hoan.com.test.model.Book"%>
<%@page import="java.util.List"%>
<%@page import="com.liferay.portal.kernel.util.ListUtil"%>
<%@ include file="/html/library/init.jsp" %>

<liferay-ui:success key="loadBookListSuccessfully" message="Book list was loaded!"/>
<liferay-ui:success key="loadBookListSuccessfully" message="welcome"/>
<liferay-ui:error key="error" message="Book list was not loaded!"/>
<liferay-ui:error key="error" message="welcome"/>

<liferay-ui:message key='welcome' /><br/>

<%-- <ul>
	<c:forEach var="book" items="${bookList}">
		<li>${book.title}</li> 
	</c:forEach>
</ul> --%>

<portlet:actionURL name="deleteBookByBookId" var="deleteBookByBookIdURL"/>

<% 
	PortletURL portletURL = renderResponse.createRenderURL();
	portletURL.setParameter(ActionRequest.ACTION_NAME, "getAllBooksByUserId");
	portletURL.setParameter("jspPage", "list-jsp");
	List<Book> bookList = (List<Book>)session.getAttribute("bookList");
%>

<liferay-ui:search-container delta="5" emptyResultsMessage="No Book found!" iteratorURL="<%=portletURL %>">
	<liferay-ui:search-container-results
		results="<%= ListUtil.subList(bookList, searchContainer.getStart(), searchContainer.getEnd()) %>"
		total="<%= bookList.size()  %>"
	/>

	<liferay-ui:search-container-row className="hoan.com.test.model.Book" modelVar="book" keyProperty="bookId" >
		<liferay-ui:search-container-column-text value="<%= String.valueOf(book.getBookId()) %>" name="Book Id" />
		<liferay-ui:search-container-column-text value="<%= String.valueOf(book.getTitle()) %>" name="Title" />
		<liferay-ui:search-container-column-text value="<%= String.valueOf(book.getUserId()) %>" name="User Id" />
		<liferay-ui:search-container-column-text value="<%= String.valueOf(book.getCreateDate()) %>" name="Create date" />
		<liferay-ui:search-container-column-text  name="Action" >
			<a href="${deleteBookByBookIdURL}&bookId=<%=book.getBookId()%>">Delete</a>
		</liferay-ui:search-container-column-text>
	</liferay-ui:search-container-row>
	 <liferay-ui:search-iterator searchContainer="<%=searchContainer%>"  paginate="<%=true%>" />
</liferay-ui:search-container>

<br/>
<a href='<portlet:renderURL/>'>Go back</a>